home *** CD-ROM | disk | FTP | other *** search
- Path: EU.net!sun4nl!xs4all!falstaff
- From: falstaff@xs4all.nl (Falstaff)
- Newsgroups: comp.lang.c
- Subject: Re: Does C convert float to double internally ?
- Date: 3 Apr 1996 19:08:20 GMT
- Organization: XS4ALL, networking for the masses
- Message-ID: <4juib4$ivv@news.xs4all.nl>
- References: <4jsllh$hkf@harbinger.cc.monash.edu.au>
- NNTP-Posting-Host: xs1.xs4all.nl
- X-Newsreader: NN version 6.5.0 #666 (NOV)
-
- bcheung@yoyo.cc.monash.edu.au (Biggles Cheung) writes:
-
- >I was told that C compiler automatically converts "float" variable
- >internally to "double" for + - * / , etc operations. Is this true?
-
- The original K&R said so, but since K&R2 (and ANSI C) compilers
- are allowed to use single-precision-only calculations when both
- operands and the result are floats. It entirely depends on
- your compiler and the hardware it's running on what the program
- will do.
-
- >Can I force the C compiler not to do the conversion as I have an
- >assignment on finding out various computing errors of different
- >precisions?
-
- >My advice from the lecturer is to have temporary variable of
- >float to split a long equation to smaller step so that I can maximize
- >the impact of single precision number on the evaluation. Is this
- >feasible?
-
- Yes, you can use a temporary to force some subexpression to
- single precision. When you store a value in a float, you
- are guaranteed to get exactly single precision; this is often
- a 32-bit IEEE754 value, but of course your compiler may choose
- another representation.
-
- Frank
- --
- The famous GIICM now on line: http://www.xs4all.nl/~falstaff/GIICM.html
- ------------------------------------------------------------------------
- Frank A. Vorstenbosch +31-(70)-355 5241 falstaff@xs4all.nl
-